package com.enation.app.web.core.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.enation.app.web.core.model.HomePage;
import com.enation.app.web.core.service.INavigationManager;
import com.enation.framework.database.IDaoSupport;
import com.enation.framework.util.JsonUtil;

/**
 * 
 * @function 导航管理
 * @author 闯哥
 * @time 2016年11月15日 下午10:46:33
 */
@Service
public class NavigationManager implements INavigationManager {

	@Autowired
	private IDaoSupport<HomePage> daoSupport;

	@Override
	public HomePage getHomePage(String page_name) {

		String sql = "select * from es_homepage where page_name=?";
		HomePage homePage = this.daoSupport.queryForObject(sql, HomePage.class,
				page_name);

		List<Map<String, Object>> paramList = JsonUtil.toList(homePage
				.getParam());
		homePage.setParamList(paramList);

		return homePage;
	}

	@Override
	public void updateParamByid(String page_name, String param) {

		String sql = "update es_homepage set param=? where page_name=?";
		this.daoSupport.execute(sql, param, page_name);

	}

}
